Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: allow passing down machine options from nontransparent/octetcounting parsers #23

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

leodido
Copy link
Owner

@leodido leodido commented Jan 25, 2025

Fixes #21

This PR introduces breaking changes because it changes the Parser interface.
As a consequence, before merging it I'm waiting for confirmation it works in a real scenario from the grafana/alloy folks (see issue). Also, it would cause v5 to get released.

What it does

By merging in this PR,
the nontransparent and octetcounting parsers can now specify which options to pass down to the underlying syslog RFC machine parsers (RFC3164 vs RFC5424).

It introduces a syslog.ParserOption to let you do so: syslog.WithMachineOptions(opts ...syslog.MachineOption).

Example:

nontransparent.NewParserRFC3164(
  syslog.WithMachineOptions(rfc3164.WithYear(rfc3164.CurrentYear{})),
  syslog.WithListener(accumulator),
).Parse(r)

…) (delegating it to the underlying machine and their options)

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
@leodido leodido self-assigned this Jan 25, 2025
@leodido leodido changed the title feat!: ... feat!: better options Jan 25, 2025
…r options

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
…n the underlying machine options

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
…estEffor()), ...)

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
…164.CurrentYear{})

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
@leodido leodido changed the title feat!: better options feat!: allow passing down machine options from nontransparent/octetcounting parsers Jan 25, 2025
@leodido leodido marked this pull request as ready for review January 25, 2025 18:46
@leodido
Copy link
Owner Author

leodido commented Jan 28, 2025

Friendly ping @dehaansa :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There is no ability to use MachineOptions (WithYear) with nontransparent/octetcounting parsers
1 participant